<template>
    <!--能耗分类-->
    <div class="statistics_energy_consumption_category">
        <CommonTitleComponent text="月度企业能耗分类统计">
            <div class="tabswitch">
                <div v-for="(item,index) in state.tablist" :key="index" :class="state.isactive===index?'isactive':''"
                     @click="state.isactive=index">
                    {{ item.name }}
                </div>
            </div>
        </CommonTitleComponent>
        <div class="statistics_energy_consumption_category_echarts">
            <div class="carCurrent_echarts">
                <chart-view
                    :chart-option="state.equipmentStatistics"
                    :auto-resize="true"
                    height="100%"
                    style="height: 100%; z-index: 1; position: relative"
                ></chart-view>
                <div class="chartInfo">
                    <h3>150.44<i>万度</i></h3>
                    <p>月度用电</p>
                </div>
                <img src="@img/keji2.png" alt=""/>
            </div>
            <ul class="fr">
                <li>
                    <div class="fr_card">
                        <p class="blockColor"></p>
                        <div>
                            <p>150.09<i>万度</i></p>
                            <div>生产用电</div>
                        </div>
                    </div>
                    <div class="lastClass">
                        <p>15%</p>
                        <div>占比</div>
                    </div>
                </li>
                <li>
                    <div class="fr_card">
                        <p class="blockColor" style="background: #1b93fb"></p>
                        <div>
                            <p style="color: #1b93fb">3542度</p>
                            <div>办公用电</div>
                        </div>
                    </div>
                    <div class="lastClass">
                        <p style="color: #1b93fb">15%</p>
                        <div>占比</div>
                    </div>
                </li>
            </ul>
        </div>
    </div>
</template>

<script lang="ts" setup>
import {nextTick, onMounted, reactive} from "vue";
import {EchartsMethods} from "@/chart/index";

const datas = {
    alpha: 25,
    distance: 190,
    top: '-7',
    pieData: 30,
    autoRotate: false,
    internalDiameterRatio: 0.85,
    activeVal: {
        value: 120,
        rate: 55
    },
    item: [
        {
            name: '危化品生产',
            value: 80,
            itemStyle: {
                color: '#F23526'
            }
        },
        {
            name: '危化品经营',
            value: 120,
            itemStyle: {
                color: '#1B93FB'
            }
        }
    ]
};
const state = reactive({
    tablist: [
        {name: '水'},
        {name: '电'},
        {name: '气'}
    ],
    isactive: 0,
    equipmentStatistics: {}
})
onMounted(() => {
    nextTick(() => {
        state.equipmentStatistics = EchartsMethods.equipmentStatistics(datas);
    });
});
</script>

<style scoped lang="scss">
.statistics_energy_consumption_category {
    padding-top: 10px;
    height: 100%;

    .tabswitch {
        display: flex;
        justify-content: space-between;
        align-items: center;

        > div {
            width: 40px;
            height: 20px;
            text-align: center;
            line-height: 20px;
            background: rgba(27, 147, 251, .2);
            border-radius: 10px;
            font-size: 12px;
            color: #FFFFFF;
            margin-right: 8px;
            cursor: pointer;

            &:last-child {
                margin-right: 0;
            }
        }

        .isactive {
            background: #447AB8;
        }
    }

    &_echarts {
        height: 93%;
        display: flex;
        align-items: center;

        .fr {
            flex: 1;
            padding-right: 20px;

            li {
                display: flex;
                align-items: center;
                justify-content: space-between;
                margin-bottom: 14px;

                &:last-of-type {
                    margin-bottom: 0;
                }

                .lastClass {
                    div {
                        @include fontCustomStyle(#fff, 12px);
                    }

                    p {
                        color: rgba(72, 224, 162, 1);
                        @include pmzd();
                        font-size: 14px;
                        margin-bottom: 2px;

                    }
                }

                .fr_card {
                    display: flex;
                    align-items: center;

                    > div {
                        p {
                            color: rgba(72, 224, 162, 1);
                            @include pmzd();
                            font-size: 14px;
                            margin-bottom: 2px;

                            i {
                                font-style: normal;
                                font-family: Source Han Sans CN;
                                font-weight: 400;
                                font-size: 12px;
                                margin-left: 2px;
                            }
                        }

                        div {
                            @include fontCustomStyle(#fff, 12px);
                        }
                    }

                    .blockColor {
                        width: 10px;
                        height: 6px;
                        background: rgba(72, 224, 162, 1);
                        margin-right: 10px;
                    }
                }
            }
        }

        .carCurrent_echarts {
            position: relative;
            height: 100%;
            width: 50%;

            .chartInfo {
                position: absolute;
                left: 0;
                top: 45px;
                text-align: center;
                width: 100%;
                color: #fff;
                z-index: 1;

                h3 {
                    font-size: 20px;

                    i {
                        font-style: normal;
                        font-size: 12px;
                        font-weight: normal;
                        margin-left: 3px;
                    }
                }

                p {
                    color: #dfeef3;
                    font-size: 12px;
                }
            }

            img {
                position: absolute;
                left: 4px;
                top: 50%;
                margin-top: -40px;
                width: 92%;
                height: 80px;
                z-index: 0;
            }
        }
    }
}
</style>